import java.util.*;
//
// IUT de Nice / Departement informatique / Module APO Java
// Annee 2011_2012 - Himalaya
//
// Classe T_Plateau_N2 - Tests unitaires des accesseurs 
//
// Auteur : A.Marongiu et S.Guery
//

public class T_Plateau_N2 {

   public static void main (String[] args) {

		 Tests.Begin("Himalaya.Plateau", "1.0.0");
			//--- Village	
		     	HashMap<Integer,Ressource>  HmapRessources = new HashMap<Integer,Ressource>();
		 		Commande commande = new Commande();
		
				Village village1 = new Village(1,1,HmapRessources,commande,false,"blanc");
				Village village2 = new Village(2,1,HmapRessources,commande,false,"blanc");
				Village village3 = new Village(3,1,HmapRessources,commande,false,"blanc");
	
				Village[] tabVillage = new Village[3];
				
				tabVillage[0] = village1;
				tabVillage[1] = village2;
				tabVillage[2] = village3;
				
			// --- Sentiers
				Sentier sentier1 = new Sentier("terre",village1,village2);
				Sentier sentier2 = new Sentier("pierre", village2,village3);
				Sentier sentier3 = new Sentier("glace",village3,village1);
	
				Sentier matSentiers[][] = new Sentier[4][4];
				
				matSentiers[1][2] = sentier1; 
				matSentiers[2][3] = sentier2; 	
				matSentiers[3][1] = sentier3; 	
						
			// --- Regions
				ArrayList<Village> villagesR1 = new ArrayList<Village>();
				villagesR1.add(village1);
				villagesR1.add(village2);
				ArrayList<Village> villagesR2 = new ArrayList<Village>();
				villagesR2.add(village2);
				villagesR2.add(village3);
				ArrayList<Village> villagesR3 = new ArrayList<Village>();
				villagesR3.add(village3);
				villagesR3.add(village1);
				
				Region region1 = new Region(1,0,villagesR1);
				Region region2 = new Region(2,0,villagesR2);
				Region region3 = new Region(3,0,villagesR3);
		
				HashMap<Integer,Region>  HmapRegions = new HashMap<Integer,Region>();

    			HmapRegions.put(1,region1);
    			HmapRegions.put(2,region2);
    			HmapRegions.put(3,region3);
	
				Plateau p = new Plateau(tabVillage,matSentiers,HmapRegions);
				
         Tests.Design("Controle des accesseur de consultation", 3); {

            Tests.Case("getVillage()"); {
            	int k;
            	String chaineVillages="";
            	if (p.getVillages() != null) {
        			for(k=0;k<(p.getVillages()).length;k++) {
        				if((p.getVillages())[k]!=null)
        				chaineVillages +=((p.getVillages())[k]).getNumero() + " ";
        			}
        		}
        		
            	Tests.Unit("1 2 3 ",chaineVillages);
            }
            
            Tests.Case("getSentier()"); {	
            	int i,j;
            	String chaineSentiers="";
            	
            	if (p.getSentiers() != null) {
        			for(i=0;i<p.getSentiers().length;i++) {
        				for(j=0;j<p.getSentiers().length;j++) {
        					if(p.getSentiers()[i][j]!=null)				
        					chaineSentiers += ((Sentier)(p.getSentiers()[i][j])).getType() + " ";
        				}
        			}
        		}
    			Tests.Unit("terre pierre glace ",chaineSentiers);
            }
            
            Tests.Case("getRegion()"); {
    			Tests.Unit("{1=[numero=1, nombre de Delegation=0], 2=[numero=2, nombre de Delegation=0], 3=[numero=3, nombre de Delegation=0]}",p.getRegions()+"");
            }
         }
         
         Tests.Design("Controle des accesseurs de modification", 3); {

             Tests.Case("setVillage()"); {
  		
 				Village village4 = new Village(4,1,HmapRessources,commande,false,"blanc");
 				Village village5 = new Village(5,1,HmapRessources,commande,false,"blanc");
 				Village village6 = new Village(6,1,HmapRessources,commande,false,"blanc");
 	
 				Village[] tabVillage2 = new Village[3];
 				
 				tabVillage2[0] = village4;
 				tabVillage2[1] = village5;
 				tabVillage2[2] = village6;
 				
 				p.setVillages(tabVillage2);
             	Tests.Unit("Plateau [ villages=(4 5 6 ), " +
            						"sentiers=(terre pierre glace ), " +
            						"regions=([numero=1, nombre de Delegation=0][numero=2, nombre de Delegation=0][numero=3, nombre de Delegation=0]) ]", p.toString());
             }
             
             Tests.Case("setSentier()"); {
            	Sentier sentier4 = new Sentier("glace",village1,village2);
 				Sentier sentier5 = new Sentier("terre", village2,village3);
 				Sentier sentier6 = new Sentier("pierre",village3,village1);
 	
 				Sentier matSentiers2[][] = new Sentier[4][4];
 				
 				matSentiers2[1][2] = sentier4; 
 				matSentiers2[2][3] = sentier5; 	
 				matSentiers2[3][1] = sentier6; 
 				
 				p.setSentiers(matSentiers2);
          		
 				Tests.Unit("Plateau [ villages=(4 5 6 ), " +
            						"sentiers=(glace terre pierre ), " +
            						"regions=([numero=1, nombre de Delegation=0][numero=2, nombre de Delegation=0][numero=3, nombre de Delegation=0]) ]", p.toString());
             }
             
             Tests.Case("setRegion()"); { 				
 				Region region4 = new Region(4,1,villagesR1);
 				Region region5 = new Region(5,2,villagesR2);
 				Region region6 = new Region(6,3,villagesR3);
 		
 				HashMap<Integer,Region>  HmapRegions2 = new HashMap<Integer,Region>();

     			HmapRegions2.put(1,region4);
     			HmapRegions2.put(2,region5);
     			HmapRegions2.put(3,region6);
     			
     			p.setRegions(HmapRegions2);
          		
     			Tests.Unit("Plateau [ villages=(4 5 6 ), " +
            						"sentiers=(glace terre pierre ), " +
            						"regions=([numero=4, nombre de Delegation=1][numero=5, nombre de Delegation=2][numero=6, nombre de Delegation=3]) ]", p.toString());
             }
             
          }
      Tests.End();       
   }
}
